<%@ page language="java" pageEncoding="UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%@ include file="/common/res.jsp" %>
    <%@ include file="/common/res-select2.jsp" %>
    <%@ include file="/common/res-datatable.jsp" %>
    <%@ include file="/common/res-fileupload.jsp" %>
    <link rel="stylesheet" href="${ctx}/static/css/bootstrap.min-v3.3.0.css"/>
	<link rel="stylesheet" href="${ctx}/static/css/base.css">
    <link href="${ctx}/static/css/merchant/merchant.css" rel="stylesheet">
    <title>洗车工管理</title>
</head>
<body>
<%@ include file="/common/head.jsp" %>
<div class="wrap-container">
    <div class="row">
        <div class="col-md-3 col-lg-2">
            <%@ include file="/common/left.jsp" %>
        </div>
        <div class="col-md-9 col-lg-10">
            <div class="cms-common-content">
                <h3>洗车工管理</h3>
                
                <div id="baseInfoShow">
              	 <h4 style="margin-top: 0;" >基本信息&nbsp;<a  href="javascript:;" onclick="editBaseInfo()">编辑</a></h4>
               	 <div class="bltitle-content">     
                   <table class="cms-detail-table fLeft" cellpadding="0" cellspacing="0" style="width:850px;">
                   		  <tr>
                          		<td>UID：<span id="washerIdShow">${washer.id}</span></td>
                                <td>注册时间：<fmt:formatDate value="${washer.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                
                          </tr>
                          
                          <tr>
                          		<td>姓名：<span id="userNameShow">${washer.userName}</span></td>
                          		<td>电话号码：<span id="phoneNoShow">${washer.phoneNo}</span></td>
                          </tr>

                          <tr>
                                <td>身份证号：<span id="idNumberShow">${washer.idNumber}</span></td>
                                <td>地址：<span id="addressShow">${washer.address}</span></td>
                          </tr>
                          
                          <tr>
                              <td>性别：<span id="sexShow">
                                  <c:if test="${washer.sex=='1'}">男</c:if>
                                  <c:if test="${washer.sex=='2'}">女</c:if>
                              </span></td>
                          		
                          		<c:if test="${washer.isValid=='1'}">
                                    <td>状态：可用</td>
                                </c:if>
                                <c:if test="${washer.isValid=='0'}">
                                    <td>状态：停用</td>
                                </c:if>
                          		
                          </tr>
                          <tr>
                               <td colspan="2">备注：<span id="remark">${washer.remark}</span></td>
                          </tr>
                   </table>
                 </div>
            </div>
            <div id="baseInfoEdit">
               <h4 style="margin-top: 0;">基本信息&nbsp;<a  href="javascript:;" onclick="commitBaseInfo()">提交</a></h4>
               <div class="bltitle-content">     
                   <table class="cms-detail-table fLeft" cellpadding="0" cellspacing="0" style="width:850px;">

                       <tr>
                           <td>UID： <input id="washerIdEdit" value="${washer.id}" type="text" readonly="readonly"></td>
                           <td>注册时间：<fmt:formatDate value="${washer.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>

                       </tr>

                       <tr>
                           <td>姓名：<input id="userNameEdit" value="${washer.userName}" type="text"/></td>
                           <td>电话号码：<input id="phoneNoEdit" value="${washer.phoneNo}" type="text"/></td>
                       </tr>

                       <tr>
                           <td>身份证号：<input id="idNumberEdit" value="${washer.idNumber}" type="text"/></td>
                           <td>地址：<input id="addressEdit" value="${washer.address}" type="text"/></td>
                       </tr>

                       <tr>
                           <td>性别：
                               <select id="sexEdit">
                                   <option value ="1" <c:if test="${washer.sex=='1'}">selected="selected"</c:if> >男</option>
                                   <option value ="2" <c:if test="${washer.sex=='2'}">selected="selected"</c:if> >女</option>
                               </select>
                           </td>

                           <td>状态：
                               <select id="isValidEdit">
                                   <option value ="1" <c:if test="${washer.isValid=='1'}">selected="selected"</c:if> >可用</option>
                                   <option value ="0" <c:if test="${washer.isValid=='0'}">selected="selected"</c:if> >停用</option>
                               </select>
                           </td>

                       </tr>
                       <tr>
                           <td colspan="2">备注：<input id="remarkEdit" type="text" class="shenhe001" value="${washer.remark}" onfocus="if (value =='请输入备注'){value =''}" onblur="if (value ==''){value='请输入备注'}" />
                           </td>
                       </tr>
                   </table>
              </div>
            </div>
           
           
            <h4>洗车工头像</h4>
                <form  method="post" id="inputFormHeader" name="inputForm" class="form-horizontal" style="padding:5px 20px 0 0;"  role="form">
                <div class="form-group">
                    <div class="col-md-1 col-xs-1"></div>
                    <div class="col-md-10 col-xs-10"  >
                        <c:if test="${washer.headUrl!=''}">
                        <img src="${washer.headUrl}"/>
                        </c:if>
                    </div>
                </div ><!--/.form-group-->
                <p>&nbsp;</p>
                <div class="form-group">
                    <div class="col-md-1 col-xs-1"  ></div>
                    <div class="col-md-10 col-xs-10"  >
                        <span class="btn btn-primary fileinput-button" >
                            <i class="fa fa-upload"></i>
                            <span>上传图片</span>
                            <input id="imgfile" type="file" name="multipartFile"  >
                        </span>
                    </div>
                </div ><!--/.form-group-->
                </form>
            </div>
            <!--/.col-md-12-->
        </div>
        <!--/.row-->
    </div>
</div>
<script>


$(function () {

    var $inputFormHeader = $('#inputFormHeader');
    $inputFormHeader.find('#imgfile').fileupload({
            url: P.ctx+'/api/image/upload',
            dataType: 'json',
            maxFileSize: 5000000, // 5 MB,
            singleFileUploads: true,//一次只上传一个文件
            acceptFileTypes: /(\.|\/)(gif|jpg|png|bmp|jpeg)$/i,
            formData: {type:'1'},
            done: function (e, resp) {
                //上传完成之后回调刷新。
                var imgData = resp.result.attributes['img'];
                var param = {}
                param.id=$("#washerIdEdit").val();
                param.headUrl=imgData.name;
                $.ajax({
                    type: "POST",
                    url: "${ctx}/op/washer/update",
                    data:param,
                    success: function(resp){
                        location.reload();
                    }
                });
            }
    }).on('fileuploadprocessalways', function (e, data) {
        var index = data.index, file = data.files[index];
        if (file.error) {
            P.messager({content: '上传图片失败', type: 'error'});
        }
    });
});//Dom ready

$("#baseInfoShow").show();
$("#baseInfoEdit").hide();

function editBaseInfo(){
     $("#baseInfoShow").hide();
     $("#baseInfoEdit").show();
}

function commitBaseInfo(){
       $("#baseInfoShow").show();
       $("#baseInfoEdit").hide();
       
       var param = {};
       param.id=$("#washerIdEdit").val();
       param.userName=$("#userNameEdit").val();
       param.phoneNo=$("#phoneNoEdit").val();
       param.idNumber=$("#idNumberEdit").val();
       param.address=$("#addressEdit").val();
       param.sex=$("#sexEdit").val();
       param.isValid=$("#isValidEdit").val();
       $.ajax({
	        type: "POST",
	        url: "${ctx}/op/washer/update",
	        data:param,
	        success: function(resp){
	            P.messager({content:resp.msg,type:resp.success==true?'success':'error'}) ;
	            location.reload();
	        }
      });
      
}


</script>
<%--商户图片模板--%>
<script id="headerTpl" type="text/x-mustache">
  {{#.}}
    <li >
        <input type="hidden" name="imgId" value="{{id}}" >
        <div   class="remove"><a href="javascript:;" title="点击删除" >X</a></div>
        <img src="{{imgUrl}}" alt="{{img}}" title="{{img}}"/>
        <div class="clearfix">
        </div>
    </li>
  {{/.}}
</script>
</body>
</html>